//
//  RateListCell.swift
//  ImGuider X
//
//  Created by 陆涛 on 2018/10/12.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class RateListCell: UITableViewCell {

    @IBOutlet weak var flagImageView: UIImageView!
    
    @IBOutlet weak var currencyLabel: UILabel!
    
    @IBOutlet weak var selectTagBtn: UIButton!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    
    var rate:Rate? {
        
        didSet {
            
            selectTagBtn.setTitle(LocalizedString("currency_selected")+" ✓", for: .normal)
            
            flagImageView.setImage(string: rate?.pictures, placeholder: UIImage(named:"placeholder_squ")!)
            currencyLabel.text = "\(rate?.smartName ?? "")-\(rate?.code ?? "")"
            
             let storekeys = RateManager.share.storeKeysList
            
            if let code = rate?.code, storekeys.contains(code) {
                
                selectTagBtn.isHidden = false
            } else {
                
                selectTagBtn.isHidden = true
            }
            
        }
    }
}
